<template>
  <div class="maina">
    <arrow :topList="topList"></arrow>
    <div>
      <div class="content">
        <article class="content_box">
          <div class="title_left">运营事项 > 账号管理</div>

          <!-- <div @click="goEdit()">点我详情list，编辑或者添加</div> -->

          <div class="app-container">
            <div style="margin-left: -43px;"> <el-form :model="queryParams" ref="queryForm" size="small" :inline="true"
                v-show="showSearch" label-width="100px">
                <el-form-item label="关键词：" prop="keyword">
                  <el-input v-model="queryParams.keyword" placeholder="请输入关键词" clearable
                    @keyup.enter.native="handleQuery" />
                </el-form-item>

                <el-form-item label="账号状态：" prop="type">
                  <el-select v-model="queryParams.type" placeholder="请选择类型">
                    <el-option v-for="item in status" :key="item.value" :label="item.label" :value="item.value">
                    </el-option>
                  </el-select>
                </el-form-item>


                <el-form-item>
                  <el-button type="primary" icon="el-icon-search" style="background-color: #165DFF;border-color: #165DFF;"
                    @click="handleQuery">搜索</el-button>
                  <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
                </el-form-item>
              </el-form></div>

            <el-row :gutter="10" class="mb8">

              <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
            </el-row>

            <el-table v-loading="loading" :data="topicList" size="medium" @selection-change="handleSelectionChange">
              <el-table-column type="selection" width="55" align="center" />
              <el-table-column label="账号编号" width="200" prop="showXh" />
              <el-table-column label="账号用户名" align="center" prop="userName" />
              <el-table-column label="账号名称" align="center" prop="authenticationName" />
              <el-table-column label="联系方式" align="center" prop="tel" />
              <el-table-column label="最后更新时间" align="center" prop="updateTime" />
              <el-table-column label="账号状态" align="center" prop="examineStatus">
                <template slot-scope="scope">
                  <el-tag v-if="scope.row.status == 0" type="success">正常</el-tag>
                  <el-tag v-if="scope.row.status == 1" type="danger">停用(永久停用)</el-tag>
                  <el-tag v-if="scope.row.status == 3" type="warning">短期停用</el-tag>
                </template>
              </el-table-column>
              <el-table-column label="认证资料审核状态" align="center" prop="examineStatus">
                <template slot-scope="scope">
                  <el-tag v-if="scope.row.examineStatus == 0" type="info">未审核</el-tag>
                  <el-tag v-if="scope.row.examineStatus == 1" type="success">通过</el-tag>
                  <el-tag v-if="scope.row.examineStatus == 2" type="danger">未通过</el-tag>
                  <el-tag v-if="scope.row.examineStatus == 3" type="warning">待提交认证</el-tag>
                </template>
              </el-table-column>
              <el-table-column label="原因" align="center" prop="actualExamineUserid" />
              <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
                <template slot-scope="scope">
                  <el-button style="border-color:#165DFF ;color: #165DFF;" @click="handleExam(scope.row)">{{
                    scope.row.examineStatus == 1 ? '管理' : '审核' }} </el-button>
                </template>
              </el-table-column>
            </el-table>

            <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum"
              :limit.sync="queryParams.pageSize" @pagination="getList" />


            <el-dialog title="基本信息" :visible.sync="openn" width="750px" center append-to-body>
              <div class="jibenxin">
                <div class="yongxinitem">
                  用户名：{{ form.authenticationName }}
                </div>
                <div class="yongxinitem">
                  姓名：{{ form.userName }}
                </div>
                <div class="yongxinitem" v-if="form.roleType == 1">
                  类别：创作者(个人)
                </div>
                <div class="yongxinitem" v-if="form.roleType == 2">
                  类别：创作者(机构)
                </div>
                <div class="yongxinitem" v-if="form.roleType == 3">
                  类别：新媒体
                </div>
                <div class="yongxinitem" v-if="form.roleType == 4">
                  类别：审核者
                </div>
                <div class="yongxinitem">
                  联系方式：{{ form.userName }}
                </div>
                <div class="yongxinitem">
                  简介：{{ form.shortDescription ? form.shortDescription : "暂无简介" }}
                </div>
                <div class="yongxinitem">
                  已授权账号： <el-tag v-for="item in form.authorizedAccountList" style="margin-right: 20px;" type="info">{{
                    item.accountName }}</el-tag>
                </div>
                <div class="yongxinitem">
                  从业证/用户凭证：<img style="width: 500px;" :src="http + form.proofUrl" />
                </div>
              </div>
              <el-divider></el-divider>
              <div style="padding-left: 95px;">
                <div class="titlefen">管理操作: <el-radio style="margin-left: 20px;" v-model="tongvalue"
                    label="1">通过</el-radio>
                  <el-radio v-model="tongvalue" label="2">驳回</el-radio>
                  <el-radio v-model="tongvalue" label="3">封禁</el-radio>
                </div>

                <div class="titlefen" v-if="tongvalue == '3'">管理操作: <el-radio style="margin-left: 20px;"
                    v-model="fengtime" label="3">三天</el-radio>
                  <el-radio v-model="fengtime" label="27">七天</el-radio>
                  <el-radio v-model="fengtime" label="15000">永久</el-radio>
                </div>

                <div style="display: flex;">
                  <span style="font-size: 18px;line-height: 50px;">操作原因:</span><el-input
                    style="width: 400px;margin-left: 20px;" v-model="reason" type="textarea" placeholder="请输入原因" />
                </div>
              </div>

              <div slot="footer" class="dialog-footer" style="text-align: center;">
                <el-button type="primary" @click="submitForm">确 定</el-button>
                <el-button @click="cancel">取 消</el-button>
              </div>
            </el-dialog>
          </div>


        </article>
      </div>
    </div>
  </div>
</template>

<script>
import arrow from '@/views/components/arrow'
import { listTopic, delMytopicChuGao } from '@/api/my/xuanti'
import { shenheList, chugaoList, yunzhang, yunzhangdetail, tijiaozhang } from '@/api/my'

export default {
  components: { arrow },
  name: '',
  dicts: ['examine_state'],
  data() {
    return {
      reason: "",
      fengtime: "3",
      invation: {
        name: '',  //邀请人姓名
        phone: '',
        job: '',
        url: ''
      },
      tableData: [{
        date: '2016-05-02',
        name: '王小虎',
        address: '上海市普陀区金沙江路 1518 弄'
      }, {
        date: '2016-05-04',
        name: '王小虎',
        address: '上海市普陀区金沙江路 1517 弄'
      }, {
        date: '2016-05-01',
        name: '王小虎',
        address: '上海市普陀区金沙江路 1519 弄'
      }, {
        date: '2016-05-03',
        name: '王小虎',
        address: '上海市普陀区金沙江路 1516 弄'
      }],
      pop: {
        title: '',  //所选专家
        search: '', //搜索专家
      },
      activeName: 'first',
      options: [{
        value: '黄金糕',
        label: '黄金糕'
      }, {
        value: '双皮奶',
        label: '双皮奶'
      }, {
        value: '蚵仔煎',
        label: '蚵仔煎'
      }, {
        value: '龙须面',
        label: '龙须面'
      }, {
        value: '北京烤鸭',
        label: '北京烤鸭'
      }],
      value: '',
      openTiShen: false,
      tongvalue: "0",
      openn: false,
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 文章选题表格数据
      topicList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        keyWords: null,
        // examineType: "2",
        // examineState: "2"
        // articleExamineState: null,
        // topicXh: null,
        // target: null,
        // digest: null,
        // outline: null,
        // results: null,
        // type: null,
        // schedule: null,
        // userId: null,
        // userName: null,
        // isDelete: null,
        // sourceMaterialId: null,
        // startTime: null,
        // endTime: null
      },
      processList: [
        { value: 1, label: '素材归集中' },
        { value: 2, label: '内容创作中' },
        { value: 3, label: '创作已完成' },
        { value: 4, label: '已提交审核' },
        { value: 5, label: '已收入成品库' },
        { value: 6, label: '产品分发中' },
      ],
      contentType: [
        { value: 1, label: '图片' },
        { value: 2, label: '视频' },
        { value: 3, label: '音频' },
        { value: 4, label: '动漫' },
        { value: 5, label: '挂图' },
      ],
      status: [
        { value: 0, label: '正常' },
        { value: 1, label: '停用(永久停用)' },
        { value: 3, label: '短期停用' }
      ],
      protos: [
        { value: 1, label: '原创' },
        { value: 2, label: '网络' },
        { value: 3, label: '委托' },
      ],
      // 表单参数
      form: {
        authenticationName: null,
        examineStatus: "0",
        tel: null,
        updateTime: null,
        userDataId: null,
        userName: null,
      },
      // 表单校验
      rules: {
        // userId: [
        //   { required: true, message: "操作人ID不能为空", trigger: "blur" }
        // ],
        // userName: [
        //   { required: true, message: "操作人姓名不能为空", trigger: "blur" }
        // ],
        // createTime: [
        //   { required: true, message: "创建时间不能为空", trigger: "blur" }
        // ],
      },
      topList: {
        title: '流程指引',
        list: [
          { name: '素材管理', img: 'blue' },
          { name: '内容创作', img: 'blue' },
          { name: '专家审核', img: 'blue' },
          { name: '产品分发', img: 'gray' },
          { name: '传播管理', img: 'gray' },
        ]
      },
      http: ""
    }
  },
  created() {
    this.getList();
    this.http = process.env.VUE_APP_ImgUrlHeader
    //  console.log(process.env.VUE_APP_ImgUrlHeader,"111")
  },
  methods: {
    handleClick(tab, event) {
      //  console.log(tab, event);
    },
    handleExam(row) {
      //提审
      this.tongvalue = "0"
      yunzhangdetail(row.userDataId).then(response => {
        this.form = response.data;
        this.form.examineStatus = "0"
        this.$forceUpdate()
        this.openn = true
        console.log(123,this.form);
      });
      //console.log(123);
    },
    goEdit() {
      this.$router.push({ path: 'xuanti_edit' })
    },
    /** 查询文章选题列表 */
    getList() {
      this.loading = false;
      yunzhang(this.queryParams).then(response => {
        // response.rows.map(v => {
        //   let typeFind = this.contentType.find(values => values.value == v.type)
        //   if (typeFind !== undefined) {  //内容类型
        //     v.type = typeFind.label
        //   }
        //   let statusFind = this.status.find(r => r.value == v.articleExamineState)
        //   if (statusFind !== undefined) {  //审核状态
        //     v.articleExamineState = statusFind.label
        //   }
        //   let protosFind = this.protos.find(params => params.value == v.copyrightType)
        //   if (protosFind !== undefined) {
        //     v.copyrightType = protosFind.label
        //   }
        //   return v
        //   // console.log(v);

        // })
        //console.log(response,12);
        this.topicList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.openn = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        authenticationName: null,
        examineStatus: null,
        tel: null,
        updateTime: null,
        userDataId: null,
        userName: null,

      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.topicId)
      this.single = selection.length !== 1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "新增文章选题";
      this.$router.push({ path: '/content/xuanti_edit', 'query': { 'type': 1 } })
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      // this.reset();
      // const topicId = row.topicId || this.ids
      // getTopic(topicId).then(response => {
      //   this.form = response.data;
      //   this.open = true;
      //   this.title = "修改文章选题";
      // });
      // console.log(row);
      this.$router.push({ path: '/content/edit_content', query: { 'type': 2, 'articleId': row.articleId, 'topicId': row.topicId } })
    },
    /** 提交按钮 */
    submitForm() {
      let msg = ""
      if (this.tongvalue == "2" || this.tongvalue == "3") {
        if (this.reason) {

        } else {
          msg = "请输入原因"
          this.$modal.msgWarning(msg);
        }
      }
      if (this.tongvalue == "0") {
        msg = "请选择操作项"
        this.$modal.msgWarning(msg);
      }

      if (msg == "") {
        tijiaozhang({
          bannedTime: "",
          examineFailReason: this.reason,
          examineStatus: this.tongvalue,
          userDataId: this.form.userDataId,
          bannedTime: this.fengtime
        }).then(res => {
          this.$modal.msgSuccess("成功");
          this.openn = false;
          this.getList();
        })
      }

      // this.$refs["form"].validate(valid => {
      //   if (valid) {
      //     if (this.form.topicId != null) {
      //       updateTopic(this.form).then(response => {
      //         this.$modal.msgSuccess("修改成功");
      //         this.open = false;
      //         this.getList();
      //       });
      //     } else {
      //       addTopic(this.form).then(response => {
      //         this.$modal.msgSuccess("新增成功");
      //         this.open = false;
      //         this.getList();
      //       });
      //     }
      //   }
      // });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const articleId = row.articleId || row.topicId || this.ids;
      this.$modal.confirm('是否确认删除内容编号为"' + row.topicXh + '"的数据项？').then(function () {
        // return delTopic(topicIds);
        return delMytopicChuGao(articleId)
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => { });
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('system/topic/export', {
        ...this.queryParams
      }, `topic_${new Date().getTime()}.xlsx`)
    }
  },

}
</script>
<style>
.has-gutter {
  /* background-color: red !important; */
}
</style>
<style lang='scss' scoped>
::v-deep .el-dialog__title {
  font-weight: bold;
}

.titlefen {
  font-size: 18px;
  line-height: 50px;
  // font-weight: bold;
}

.jibenxin {
  width: 95%;
  margin: 0 95px 0;
  display: flex;
  flex-wrap: wrap;
  padding-bottom: 20px;

  .yongxinitem {
    width: 48%;
    font-size: 16px;
    font-family: Microsoft YaHei, Microsoft YaHei;
    font-weight: 400;
    color: #666666;
    line-height: 40px;
  }
}

.maina {
  background-color: #f5f5f5;

  .content {
    margin-top: 10px;
    background-color: white !important;

    .content_box {
      padding-left: 32px;

      .title_left {
        // margin-left: 23px;
        padding-top: 31px;
        font-size: 16px;
        font-family: Microsoft YaHei, Microsoft YaHei;
        font-weight: 700;
        color: #3D3D3D;
        line-height: 21px;
      }
    }
  }
}
</style>